﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace ReporterApplication
{
    public class rQuery : IEnumerable<rQuery>
    {
        public List<XElement> Elements = new List<XElement>();

        public string GetValue()
        {
            return null;
        }

        public rQuery GetByProperty(string elementName)
        {
            var elementNames = elementName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            
            var result = new rQuery();

            foreach (var element in Elements)
            {
                foreach (var name in elementNames)
                {
                    if (element.Element(name) != null)
                        result.Elements.Add(element.Element(name));
                }
            }

            result.Elements = result.Elements.Distinct().ToList();

            return result;
        }

        public static rQuery New(XDocument xd)
        {
            var cif = cifQuery.New(xd);
            

            return null;
        }

        public IEnumerator<rQuery> GetEnumerator()
        {
            //return Data.GetEnumerator();
            return null;
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            //return Data.GetEnumerator();
            return null;
        }
    }
}
